const date1 = new Date('7/13/2010');
const date2 = new Date('12/15/2010');
console.log(getDifferenceInDays(date1, date2));
console.log(getDifferenceInHours(date1, date2));
console.log(getDifferenceInMinutes(date1, date2));
console.log(getDifferenceInSeconds(date1, date2));
function getDifferenceInDays(date1, date2) {
const diffInMs = Math.abs(date2 - date1);
return diffInMs / (1000 * 60 * 60 * 24);
}
function getDifferenceInHours(date1, date2) {
const diffInMs = Math.abs(date2 - date1);
return diffInMs / (1000 * 60 * 60);
}
function getDifferenceInMinutes(date1, date2) {
const diffInMs = Math.abs(date2 - date1);
return diffInMs / (1000 * 60);
}
function getDifferenceInSeconds(date1, date2) {
const diffInMs = Math.abs(date2 - date1);
return diffInMs / 1000;
}
dayDiff(d1:Date, d2:Date)
{
var diff = Math.abs(date1.getTime() - date2.getTime());
var diffDays = Math.ceil(diff / (1000 * 3600 * 24));
return diffDays;
}
for(let k = 0; k < this.bookingDetailsArrayRealObject.length; k++){
let dateCheckOut = this.bookingDetailsArrayRealObject[k].package.chackout;
let dateToBeCheckOut = new Date(dateCheckOut);
let today = new Date();
//let today_test = new Date();
if(this.bookingDetailsArrayRealObject[k].status){
if(dateToBeCheckOut < today){
this.bookingIdsToBeUpdated.push(this.bookingDetailsArrayRealObject[k]._id);
window.alert('true');
console.log(today.toDateString());
console.log(dateToBeCheckOut.toDateString());
console.log(this.bookingDetailsArrayRealObject[k]);
}
}
}